var game = require('./build/Debug/game');
var util = require('util');

var player = function(x, y, uid, sid, hp){
	this.x = x;
	this.y = y;
	this.hp = 100;
	this.uid = uid;
	this.sid = sid;
};

player.x = 0;
player.y = 0;
player.uid = 1;
player.sid = "123";

var dlist = new game.DList(50, 50);

var player1 = new player(10, 0, 1, "player1", 100);

dlist.PlayerEnter(player1, function(err, result){
	console.log('player1进入, 待广播列表: ');
	console.log('	' + util.inspect(result));
});


var player2 = new player(50, 50, 2, "player2", 100);
dlist.PlayerEnter(player2, function(err, result)
{
	console.log('player2进入, 待广播列表: ');
	console.log('	' + util.inspect(result));
});

var player3 = new player(9, -50, 3, "player3", 100);
dlist.PlayerEnter(player3, function(err, result){
	console.log('player3进入, 待广播列表: ');
	console.log('	' + util.inspect(result));
});


var player4 = new player(80, 90, 4, "player4", 100);
dlist.PlayerEnter(player4, function(err, result){
	console.log('player4进入, 待广播列表: ');
	console.log('	' + util.inspect(result));
});

var player5 = new player(-20, -30, 5, "player5", 100);
dlist.PlayerEnter(player5, function(err, result){
	console.log('player5进入, 待广播列表: ');
	console.log('	' + util.inspect(result));
});

var arr = dlist.test();
console.log("所有角色：");
console.log(arr);

console.log('------------------------------------------------------------');
dlist.PlayerLeave(player1.uid, function(err, result){
	console.log('player1离开，待广播列表: ');
	console.log('	' + util.inspect(result));
});



dlist.PlayerEnter(player1, function(err, result){
	console.log('player1进入, 待广播列表: ');
	console.log('	' + util.inspect(result));
});

dlist.PlayerLeave(player2.uid, function(err, result){
	console.log('player2离开，待广播列表: ');
	console.log('	' + util.inspect(result));
});

dlist.PlayerLeave(player4.uid, function(err, result){
	console.log('player4离开，待广播列表: ');
	console.log('	' + util.inspect(result));
});

dlist.PlayerLeave(player3.uid, function(err, result){
	console.log('player3离开，待广播列表: ');
	console.log('	' + util.inspect(result));
});

dlist.PlayerLeave(player5.uid, function(err, result){
	console.log('player5离开，待广播列表: ');
	console.log('	' + util.inspect(result));
});

arr = dlist.test();
console.log("所有角色：");
console.log(arr);

console.log('------------------------------------------------------------');
var player3 = new player(9, -50, 3, "player3", 100);
dlist.PlayerEnter(player3, function(err, result){
	console.log('player3进入, 待广播列表: ');
	console.log('	' + util.inspect(result));
});

player1.hp = 80;
dlist.PlayerUpdate(player1, function(err, result){
	console.log('player1血量变化，待广播列表: ');
	console.log('	' + util.inspect(result));
});

var player4 = new player(80, 90, 4, "player4", 100);
dlist.PlayerEnter(player4, function(err, result){
	console.log('player4进入, 待广播列表: ');
	console.log('	' + util.inspect(result));
});

var player5 = new player(-20, -30, 5, "player5", 100);
dlist.PlayerEnter(player5, function(err, result){
	console.log('player5进入, 待广播列表: ');
	console.log('	' + util.inspect(result));
});

arr = dlist.test();
console.log("所有角色：");
console.log(arr);

console.log('---------------------------------------------------------------');
player3.x = 60;
player3.y = 50;
dlist.PlayerMove(player3.uid, player3.x, player3.y, function(err, leaveArr, updateArr, enterArr){
	console.log('player3移动，待广播列表: ');
	console.log('	leave列表: ' + util.inspect(leaveArr));
	console.log('	update列表: ' + util.inspect(updateArr));
	console.log('	enter列表: ' + util.inspect(enterArr));
});
